/*
 * License GNU LGPL
 * Copyright (C) 2012 Amrullah <amrullah@panemu.com>.
 */
package com.abc.cheque.ui.form;


import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;

import com.abc.cheque.control.DateField;



/**
 *
 * @author Amrullah <amrullah@panemu.com>
 */
public class DateControl extends BaseControl<Date, DateField> {
    private DateField dateField;

    public DateControl() {
        this("");
    }

    public DateControl(String propertyName) {
        super(propertyName, new DateField());
        dateField = getInputComponent();
    }

    @Override
    protected void bindValuePropertyWithControl(DateField inputControl) {
        value.bind(inputControl.selectedDateProperty());
    }

    @Override
    public void setValue(Date value) {
        dateField.setSelectedDate(value);
    }

    public ObjectProperty<Locale> localeProperty() {
        return dateField.localeProperty();
    }

    public void setPromptText(String promptText) {
        dateField.setPromptText(promptText);
    }

    public ObjectProperty<DateFormat> dateFormatProperty() {
        return dateField.dateFormatProperty();
    }

    public void setDateFormat(DateFormat dateFormat) {
        dateField.setDateFormat(dateFormat);
    }

    public DateFormat getDateFormat() {
        return dateField.getDateFormat();
    }

    public void setLocale(Locale locale) {
        dateField.setLocale(locale);
    }

    public Locale getLocale() {
        return dateField.getLocale();
    }

    public ReadOnlyBooleanProperty showingCalendarProperty() {
        return dateField.showingCalendarProperty();
    }

    public void showCalendar() {
        dateField.showCalendar();
    }

    public BooleanProperty showTodayButtonProperty() {
        return dateField.showTodayButtonProperty();
    }

    public boolean isShowTodayButton() {
        return dateField.isShowTodayButton();
    }

    public void setShowTodayButton(boolean showTodayButton) {
        dateField.setShowTodayButton(showTodayButton);
    }
    
}
